<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对账管理</title>
</head>
<body>
<style>
    .m15 .form-inline .form-group{
        margin-right: 15px;
    }
    #platform-tableReconciliation tr td{
        border:2px black solid;
        height:50px;
        font-size:16px;
        font-weight:700;
    }
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span>
    财务管理
    <span class="c-gray en">&gt;</span>
    对账管理
</nav>
<div class="page-container">
    <div class="row mt-20">
        <div id="platformReconciliationFormToolBars">
            <form class="form-inline" id="platformReconciliationForms">
                <!--<div class="form-group">-->
                    <!--<label class="control-label">商户名称：</label>-->
                    <!--<select class="form-control" name="bizId" id="platform-finances-bizId">-->
                        <!--<option value="">请选择</option>-->
                    <!--</select>-->
                <!--</div>-->
                <div class="form-group">
                    <label class="control-label" title="">
                        日期：
                    </label>
                    <input id="platformReconciliationTimeEnds" name="orderTimes" type="text" onfocus="WdatePicker()"
                           readonly="readonly" class="form-control Wdate" style="width:150px;">
                </div>
                <div class="form-group">
                    <label class="control-label">门店名称：</label>
                    <select class="form-control" name="shopId" id="platformReconciliationShopId-orderType">
                        <option value="0">请选择</option>
                        <option value="1">蓝岸3G服务站</option>
                        <option value="3">银河湾花园服务站</option>
                        <option value="6">清凉门服务站</option>
                    </select>
                </div>
                <span onclick="platformFinanceReconciliation.searchAction();" class="btn btn-default">查询 <i class="glyphicon glyphicon-search"></i></span>
            </form>
        </div>
        <div class="col-xs-12">
            <table id="platform-tableReconciliation" class="table table-bordered table-striped text-center" style="margin-top: 20px;">
                <tr><td>类型</td><td>支付方式</td><td>单价</td><td>数量</td><td>总计</td></tr>
            </table>
        </div>
    </div>
</div>
<script>
    //退款管理
    var platformFinanceReconciliation = {
        init: function () {
            //设置页面初次加载时，时间控件所显示的时间
            let _this = this;
            var temp;
            //昨天
            var addTime = _this.time(0);
            $("#platformReconciliationTimeEnds").val(addTime);

            //洗车
            $.ajax({
                type: "get",
                url: "cust/getReconciliations?bigType=洗车",
                async:false,
                data: $("#platformReconciliationForms").serialize(),
                dataType: "json",
                success: function (json) {
                    temp = json.length;
                    for(var i = 0;i < json.length;i++){
                        if(i==0){
                            $("#platform-tableReconciliation").append(`<tr><td style="vertical-align: middle;font-size: 30px;">${json[i].bigType}</td><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                            $("#platform-tableReconciliation td").eq(5).attr("rowspan",json.length);
                        }else {
                            $("#platform-tableReconciliation").append(`<tr><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                        }
                    }
                },
                error: function () {
                    alert("error");
                }
            });

            //美容
            $.ajax({
                type: "get",
                url: "cust/getReconciliations?bigType=美容",
                async:false,
                data: $("#platformReconciliationForms").serialize(),
                dataType: "json",
                success: function (json) {
                    for(var i = 0;i < json.length;i++){
                        if(i==0){
                            $("#platform-tableReconciliation").append(`<tr><td style="vertical-align: middle;font-size: 30px;">${json[i].bigType}</td><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                            $("#platform-tableReconciliation td").eq(6+temp * 4).attr("rowspan",json.length);
                        }else {
                            $("#platform-tableReconciliation").append(`<tr><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                        }
                    }
                },
                error: function () {
                    alert("error");
                }
            });

            //其他
            $.ajax({
                type: "get",
                url: "cust/getReconciliations?bigType=其他",
                async:false,
                data: $("#platformReconciliationForms").serialize(),
                dataType: "json",
                success: function (json) {
                    for(var i = 0;i < json.length;i++){
                        if(i==0){
                            $("#platform-tableReconciliation").append(`<tr><td style="vertical-align: middle;font-size: 30px;">${json[i].bigType}</td><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                            $("#platform-tableReconciliation td").eq(6+temp * 4).attr("rowspan",json.length);
                        }else {
                            $("#platform-tableReconciliation").append(`<tr><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                        }
                    }
                },
                error: function () {
                    alert("error");
                }
            });

        },
        //查询
        searchAction: function () {
            var temp;
            //洗车
            $.ajax({
                type: "get",
                url: "cust/getReconciliations?bigType=洗车",
                async:false,
                data: $("#platformReconciliationForms").serialize(),
                dataType: "json",
                success: function (json) {
                    $("#platform-tableReconciliation").html("");
                    $("#platform-tableReconciliation").html(`<tr><td>类型</td><td>支付方式</td><td>单价</td><td>数量</td><td>总计</td></tr>`);
                    temp = json.length;
                    for(var i = 0;i < json.length;i++){
                        if(i==0){
                            $("#platform-tableReconciliation").append(`<tr><td style="vertical-align: middle;font-size: 30px;">${json[i].bigType}</td><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                            $("#platform-tableReconciliation td").eq(5).attr("rowspan",json.length);
                        }else {
                            $("#platform-tableReconciliation").append(`<tr><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                        }
                    }
                },
                error: function () {
                    alert("error");
                }
            });

            //美容
            $.ajax({
                type: "get",
                url: "cust/getReconciliations?bigType=美容",
                async:false,
                data: $("#platformReconciliationForms").serialize(),
                dataType: "json",
                success: function (json) {
                    for(var i = 0;i < json.length;i++){
                        if(i==0){
                            $("#platform-tableReconciliation").append(`<tr><td style="vertical-align: middle;font-size: 30px;">${json[i].bigType}</td><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                            $("#platform-tableReconciliation td").eq(6+temp * 4).attr("rowspan",json.length);
                        }else {
                            $("#platform-tableReconciliation").append(`<tr><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                        }
                    }
                },
                error: function () {
                    alert("error");
                }
            });

            //其他
            $.ajax({
                type: "get",
                url: "cust/getReconciliations?bigType=其他",
                async:false,
                data: $("#platformReconciliationForms").serialize(),
                dataType: "json",
                success: function (json) {
                    for(var i = 0;i < json.length;i++){
                        if(i==0){
                            $("#platform-tableReconciliation").append(`<tr><td style="vertical-align: middle;font-size: 30px;">${json[i].bigType}</td><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                            $("#platform-tableReconciliation td").eq(6+temp * 4).attr("rowspan",json.length);
                        }else {
                            $("#platform-tableReconciliation").append(`<tr><td>${json[i].orderType}</td>
                            <td>${json[i].price}</td><td>${json[i].num}辆</td><td>${json[i].money}元</td></tr>`);
                        }
                    }
                },
                error: function () {
                    alert("error");
                }
            });
        },
        //获取时间的方法
        time: function (index) {
            var today = new Date();
            today.setMonth(today.getMonth() + index);
            var h = today.getFullYear();
            var m = today.getMonth() + 1;
            var d = today.getDate()-1;
            m = m < 10 ? "0" + m : m;
            d = d < 10 ? "0" + d : d;
            return h + "-" + m + "-" + d;
        }
    };

    platformFinanceReconciliation.init();
</script>
</body>
</html>